package com.ext.portlet.registration.action;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.struts.PortletAction;
import com.liferay.portal.util.PortalUtil;

public class ManageRegistration extends PortletAction{
	
	public ActionForward render(ActionMapping mapping, ActionForm form,
			PortletConfig config, RenderRequest req, RenderResponse res) throws Exception {
		
		String forward = "";
		
		String cmd = ParamUtil.getString(req, Constants.CMD);
		String registration = req.getParameter("registration");	
		HttpServletRequest request = PortalUtil.getHttpServletRequest(req);
		HttpSession session = request.getSession();
		
		if (cmd.equals(Constants.MOVE)) {									
			
			
	        if(registration != null && registration.equals("1")){
				
	        	session.setAttribute("manage", "blossom");
				forward = "portlet.ext.registration.blossom.registration";
								
			}else if(registration != null && registration.equals("2")){
				
				session.setAttribute("manage", "campus");
				forward = "portlet.ext.registration.campus.registration";
				
				
			}else if(registration != null && registration.equals("3")){
				
				session.setAttribute("manage", "mainstay");
				forward = "portlet.ext.registration.mainstay.registration";
				
			}else {
				
				session.setAttribute("manage", "");
				forward = "portlet.ext.registration.view";
				
			}	
	        //forward = "portlet.ext.registration.view";
			
		}	
		
		if (cmd.equals("listPage")) {
			
			 if(registration != null && registration.equals("1")){
				 session.setAttribute("manage", "blossomList");
				 forward = "portlet.ext.registration.blossomlist";
				 
			 }else if(registration != null && registration.equals("2")){
				 session.setAttribute("manage", "campusList");
				 forward = "portlet.ext.registration.campus.campusList";					
				// forward = "portlet.ext.registration.campus.campusList";
				 
			 }else if(registration != null && registration.equals("3")){
				 session.setAttribute("manage", "mainstayList");
				 forward = "portlet.ext.registration.mainstay.mainstayList";					
				// forward = "portlet.ext.registration.mainstay.mainstayList";
				 
			 }
			// forward = "portlet.ext.registration.view";
				
		}
		
		return mapping.findForward(forward);	
		
		
	}	
	
	public void processAction(
			ActionMapping mapping, ActionForm form, PortletConfig config,
			ActionRequest req, ActionResponse res)
				throws Exception {
		
		String cmd = ParamUtil.getString(req, Constants.CMD);		
	}

}
